<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="/home/css/_reset.css" />
		<link rel="stylesheet" type="text/css" href="/home/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/home/css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_746537_q3awcgy5jx.css"/>
		<link rel="stylesheet" type="text/css" href="/home/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="/home/css/speci_counter.css" />
	</head>
	<body style="overflow-x: hidden;">
		<div class="speci_counter">
			<div class="top">
				<a href="javascript:history.back(-1)" class="back">
					<i class="iconfont">&#xe615;</i></a>
				合伙人申请
			</div>
			<div class="speci_input">
				<ul>
					<li>
						<div class="input_wrap">
							<p><span>申请人姓名</span><small>name</small></p>
							<input type="text" name="p_name" id="p_name" value="" />
						</div>
					</li>
					<li>
						<div class="input_wrap">
							<p><span>申请人身份证</span><small>IDcard</small></p>
							<input type="text" name="" id="p_card" value="" />
						</div>
					</li>
					<li>
						<div class="input_wrap">
							<p><span>申请人联系电话</span><small>contact number</small></p>
							<input type="text" name="" id="p_tel" value="" />
						</div>
					</li>
					<li>
						<div class="input_wrap">
							<p><span>申请人联系地址</span><small>contact address</small></p>
							<input type="text" name="" id="p_address" value="" />
						</div>
					</li>
					<li>
						<div class="input_wrap">
							<p><span>店主照片</span><small>photo</small></p>
							<div class="layui-upload">
								<img class="layui-upload-img" id="demo1" width="100" height="100" style="display: none;"/>
							  <button type="button" class="layui-btn" id="test2"><i class="iconfont icon-jia"></i></button>
							</div>
						</div>
					</li>
				</ul>
				<a id="partner">立即申请</a>
			</div>
		</div>
	</body>
	<script src="/home/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="/home/js/iconfont.js" type="text/javascript" charset="utf-8"></script>
	<script src="/home/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="/home/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script>
	layui.use('upload', function(){
	  var upload = layui.upload;
	   
	  //执行实例
	  var uploadInst = upload.render({
	    elem: '#test2' //绑定元素
	    ,url: '/home/index/upload' //上传接口
	    ,done: function(res){
	      //上传完毕回调
	      if(res.code==0){
	      	$('#demo1').attr('src', '/upload/'+res.data);
	      	$('#demo1').css('display', 'block');
	      }
	    }
	    ,error: function(){
	      //请求异常回调
	    }
	  });
	});
	layui.use('layer', function(){
  var layer = layui.layer;
  layer.ready(function(){
  	layer.open({
  	title: 'Tips'
  	,shade:0.8
  ,content: '警告警告'
});  
});   
});
	/* 申请合伙人 */
	$('#partner').click(function(){
    	var p_name =$("#p_name").val();
    	var p_card  = $('#p_card').val();
    	var p_tel =$("#p_tel").val();
    	var p_address  = $('#p_address').val();
    	var p_pic = $('.speci_input ul li').find('img').attr('src');
    	var reg = /^1[345678]\d{9}$/;
		var card = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i;
    	if(p_name === ''){
    		layui.layer.msg('申请人姓名不能为空', {icon:5});
    		return false;
    	}else if(p_card === ''){
    		layui.layer.msg('申请人身份证号不能为空', {icon:5});
    		return false;
    	}else if(!card.test(p_card)){
    		layui.layer.msg('申请人身份证号格式不对', {icon:5});
    		return false;
    	}else if(p_tel === ''){
    		layui.layer.msg('申请人手机号码不能为空', {icon:5});
    		return false;
    	}else if(!reg.test(p_tel)){
    		layui.layer.msg('申请人手机号码格式不对', {icon:5});
    		return false;
    	}else if(p_address === ''){
    		layui.layer.msg('申请人联系地址不能为空', {icon:5});
    		return false;
    	}else if(p_pic === ''){
    		layui.layer.msg('店主照片不能为空', {icon:5});
    		return false;
    	}else{
    		$.post('/home/index/addPartner',{p_name:p_name,p_card:p_card,p_tel:p_tel,p_address:p_address,p_pic:p_pic},function(res){
    			if(res.msg == '申请成功,等待审核'){
    				layui.layer.msg(res.msg, {icon:6});
                    setTimeout(function(){
                        window.location.reload();
                    },1000);
    			}else if(res.msg=="你还没有登录,请前去登录"){
    				layui.layer.msg(res.msg,{icon:5});
    				setTimeout(function(){
                        window.location.href = '/home/login/login';
                    },1000);
    			}

    		},'json');
    	}
    });
	</script>
</html>